#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
using namespace std;
const int N = 1e5 + 10;
int st[N], idx = -1;
int head = 0;
int a[N];
string s;
int main()
{
    while(cin >> s)
    {
        memset(a, 0, sizeof a);
        idx = -1;
        bool mach = true;
        for(int i = 0; i < s.size(); ++i)
        {
            char ch = s[i];
            if(ch == '(') st[++idx] = i;
            else{
                if(idx == -1) a[head]++, mach = false;
                else
                {
                    idx--;
                    if(idx == -1)
                        head = idx + 1;
                }
            }
        }
        if(idx != -1) mach = false;
        if(mach)
            cout << "Match\n";
        // 获取答案字符串
        else
        {        
            string ans;
            int num = idx + 1;
            for(int i = 0; i < s.size(); ++i)
            {
                if(a[i])
                {
                    ans += string(a[i], '(');
                    num += a[i];
                }
                ans += s[i];
            }
            if(idx != -1) ans += string(idx + 1, ')');
            cout << num << endl << ans << endl;
        }
        
    }
    return 0;
}